package com.flyduck.system.controller;

import com.flyduck.common.annotation.IgnoreAuth;
import com.flyduck.common.vo.Result;
import com.flyduck.system.service.SysUserCenterService;
import com.flyduck.system.vo.userCenter.SysUserCenterDetailRespVO;
import com.flyduck.system.vo.userCenter.SysUserCenterUpdateAvatarReqVO;
import com.flyduck.system.vo.userCenter.SysUserCenterUpdatePasswordReqVO;
import com.flyduck.system.vo.userCenter.SysUserCenterUpdateReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: flyduck-platform
 * @description: 系统:个人信息接口
 * @author: flyduck
 * @create: 2021-03-17 20:52
 **/
@Api(tags = "系统:个人信息接口")
@RestController
@RequestMapping("/system/userCenter")
public class SysUserCenterController {

    @Autowired
    private SysUserCenterService sysUserCenterService;

    @IgnoreAuth
    @ApiOperation("查询用户中心详细信息")
    @GetMapping("/detail")
    public Result getUserCenterDetail(){
        SysUserCenterDetailRespVO personDetailRespVO = sysUserCenterService.getUserCenterDetail();
        return Result.success(personDetailRespVO);
    }

    @IgnoreAuth
    @ApiOperation("编辑用户中心信息")
    @PutMapping("/update")
    public Result updatePerson(@RequestBody SysUserCenterUpdateReqVO reqVO){
        boolean flag = sysUserCenterService.updatePerson(reqVO);
        return Result.success(flag,"编辑成功");
    }

    @IgnoreAuth
    @ApiOperation("编辑用户密码")
    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody SysUserCenterUpdatePasswordReqVO reqVO){
        boolean flag = sysUserCenterService.updatePassword(reqVO);
        return Result.success(flag,"编辑成功");
    }

    @IgnoreAuth
    @ApiOperation("编辑用户头像")
    @PutMapping("/updateAvatar")
    public Result updateAvatar(@RequestBody SysUserCenterUpdateAvatarReqVO reqVO){
        boolean flag = sysUserCenterService.updateAvatar(reqVO);
        return Result.success(flag,"编辑成功");
    }

}
